using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DomainLayer.Data.Entities;

namespace Infrastructure.Data.Mapping
{
	public class CityMap : EntityTypeConfiguration<City>
	{
		public CityMap()
		{
			// Primary Key
			this.HasKey(t => t.CityID);

			// Properties
			this.Property(t => t.CityID)
				.IsRequired()
				.HasMaxLength(10);
				
			this.Property(t => t.CityName)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.ProvinceID)
				.IsRequired()
				.HasMaxLength(10);
				
			// Table & Column Mappings
			this.ToTable("City");
			this.Property(t => t.CityID).HasColumnName("CityID");
			this.Property(t => t.CityName).HasColumnName("CityName");
			this.Property(t => t.ProvinceID).HasColumnName("ProvinceID");
			this.Property(t => t.ExpressCompanyID).HasColumnName("ExpressCompanyID");
			this.Property(t => t.IsDeleted).HasColumnName("IsDeleted");
		}
	}
}

